home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_03
/
9n03104b
< prev
next >
Wrap
Text File
|
1991-01-14
|
536b
|
27 lines
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int comp(const void *, const void *);
unsigned char *list[] = { "cat", "car", "cab",
"cap", "can" };
int main()
{
int x;
qsort(list, 5, sizeof(unsigned char *), comp);
for (x = 0; x < 5; x++)
printf("%s\n", list[x]);
return 0;
}
int comp(const void *a, const void *b)
{
unsigned **A = (unsigned char **)a;
unsigned **B = (unsigned char **)b;
return strcmp(*A, *B);
}